package cn.tt.tuantuanerp.passport.webapi.config;


import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 使用AK&SK初始化账号Client,使用阿里云的短信服务
 *
 * @author xieyuhao
 * @version 0.0.1
 */
@Configuration
public class AliyunSendSmsConfiguration {
    @Value("${aliyun.messageServer.accessKey.id}")
    private String accessId;

    @Value("${aliyun.messageServer.accessKey.secret}")
    private String accessSecret;

    @Value("${aliyun.messageServer.endpoint}")
    private String endpoint;

    @Bean
    public com.aliyun.dysmsapi20170525.Client createClient() throws Exception {
        Config config = new Config()
                // 您的 AccessKey ID
                .setAccessKeyId(accessId)
                // 您的 AccessKey Secret
                .setAccessKeySecret(accessSecret);
        // 访问的域名
        config.endpoint = endpoint;
        return new com.aliyun.dysmsapi20170525.Client(config);
    }
}
